﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeBuilder
{
    public static class DataTypeMap
    {
        private static Dictionary<string, string> map = new Dictionary<string, string>()
        {
            {"System.Int64", "long"},
            {"bigint", "long"},
            {"System.String", "string"},
            {"varchar", "string"},
            {"System.Int32", "int"},
            {"int", "int"},
            {"System.Boolean", "bool"},
            {"System.DateTime", "DateTime"},
            {"datetime", "DateTime"},
            {"System.Double", "double"},
            {"double", "double"},
            {"System.Single", "float"},
            {"float", "float"},
            {"System.Tinyint", "bool"},
            {"tinyint(1)", "bool"},
            {"System.SByte", "byte"},
            {"System.Byte", "byte"},
        };

        public static string Get(string typeName)
        {
            if (map.ContainsKey(typeName))
            {
                return map[typeName];
            }
            else
            {
                return map.FirstOrDefault(xx => xx.Key.Contains(typeName) || typeName.Contains(xx.Key)).Value;
            }
        }
    }
}
